<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use backend\models\ProjectDonation;

/* @var $this yii\web\View */
/* @var $model backend\models\ProjectDonation */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="create-form project-donation-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'donor_id')->widget(Select2::classname(), [
            'data' => \backend\models\Donor::donorList(),
            'options' => ['placeholder' => 'Выберите донора...'],
        ]); 
    ?>

    <?= $form->field($model, 'price')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'is_direct_donation')->radioList(
        [
            ProjectDonation::CONTRACT => 'Через договор',
            ProjectDonation::DIRECT => 'Без договора (прямое)',
        ])
    ?>

    <?= $form->field($model, 'is_proxy')->radioList(
        [
            ProjectDonation::PROXY => 'Да',
            ProjectDonation::OWN => 'Нет',
        ])
    ?>

    <br>
    <h2 class="main-title">Договор пожертвования</h2>
    <br>

    <div class="row">
        <?= $form->field($model, 'own_number', ['options' => ['class' => 'col-sm-4']])->textInput() ?>
        <?= $form->field($model, 'registry_number', ['options' => ['class' => 'col-sm-8']])->textInput(['readonly' => true]) ?>
    </div>

    <?= $form->field($model, 'subject')->textInput(['maxlength' => true]) ?>

    <div class="row">
        <?= $form->field($model, 'date_sign', ['options' => ['class' => 'col-sm-3']])->input('date')  ?>
        <?= $form->field($model, 'date_realize', ['options' => ['class' => 'col-sm-3']])->input('date') ?>
    </div>

    <br>
    
    <div class="row">
        <?= $form->field($model, 'contractFile', ['options' => ['class' => 'col-sm-4']])->fileInput(['accept' => '.doc,.docx,.pdf,.zip']) ?>
        <div class="col-sm-8">
            <?php 
            if(!empty($model->filename))
            {
                echo '<label class="control-label">Договор</label>';
                echo '<div class="anchor-container">';
                echo Html::a($model->filename, 'https://storage.yandexcloud.net/' . backend\models\ProjectDonation::BUCKET_NAME  . '/' . $model->filename);
                echo '</div>';
            }
            ?>
        </div>
    </div>

    <br>

    <div class="form-group">
        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
